import React from "react";

// 路由懒加载
const Home = React.lazy(() => import("../views/home"));
const Set = React.lazy(() => import("../views/set"));
const ListManage = React.lazy(() => import("../views/listManage"));
const ListAdd = React.lazy(() => import("../views/listAdd"));
const MainLayout = React.lazy(() => import("../views/mainLayout"));
const Login = React.lazy(() => import("../views/login"));
const UserList = React.lazy(() => import("../views/userList"));

// 路由类型
export interface RouteRowState {
  path: string;
  element?: JSX.Element;
  role?: string[];
  title?: string;
  hidden?: boolean;
  children?: RouteRowState[];
}

// 路由表
const ROUTER_LIST: RouteRowState[] = [
  {
    path: "/",
    element: (
      <MainLayout>
        <Home></Home>
      </MainLayout>
    ),
    title: "首页",
  },
  {
    path: "/list",
    title: "列表操作",
    children: [
      {
        path: "/list/manage",
        element: (
          <MainLayout>
            <ListManage></ListManage>
          </MainLayout>
        ),
        role: ["admin", "test"],
        title: "列表管理",
      },
      {
        path: "/list/add",
        element: (
          <MainLayout>
            <ListAdd></ListAdd>
          </MainLayout>
        ),
        title: "列表添加",
      },
      {
        path: "/set",
        element: (
          <MainLayout>
            <Set></Set>
          </MainLayout>
        ),
        title: "列表设置",
      },
    ],
  },
  {
    path: "/user",
    title: "用户操作",
    children: [
      {
        path: "/user/manage",
        title: "用户管理",
        hidden: true,
        element: (
          <MainLayout>
            <div>用户管理页面</div>
          </MainLayout>
        ),
      },
      {
        path: "/user/manage/list",
        title: "用户设置",
        children: [
          {
            path: "/user/manage/list/set",
            title: "用户列表",
            element: (
              <MainLayout>
                <UserList></UserList>
              </MainLayout>
            ),
            role: ['admin']
          },
          {
            path: "/user/manage/list/info",
            title: "用户信息",
            role: ["admin"],
            element: (
              <MainLayout>
                <div>用户信息页面</div>
              </MainLayout>
            ),
          },
        ],
      },
    ],
  },
  {
    path: "/login",
    element: <Login></Login>,
    title: "登录",
    hidden: true,
  },
];

export default ROUTER_LIST;
